An unexpected error has occurred...

I think I've seen this before...usually a script syntax issue, but I haven't found anything yet.

The specific error message is:

-R-E- DXL: <.../check_alarms_information.dxl:1435> An unexpected error has occurred: general_library.dll caused an EXCEPTION_ACCESS_VIOLATION in module general_library.dll at 00000000F08BF8A7

Backtrace:
    <.../check_alarms_information.dxl:1592> 

 

Now line 1435 looks pretty innocuous:

id=o."Absolute Number"

 

Any idea of the cause of this?

Here is some more context for this function, if it helps:

Skip alarmObjects=create 
Skip alarmReferences=create     //Skip of string arrays stored by object key
Skip alarmReferencesOrig=create //Skip of string arrays stored by object key (similar to above and with same object key, just an alternate form of the string values that correspond to printable versions of the alarm references)
Buffer alarmRefsGood=create         
Buffer alarmRefsMissingLink=create  
Buffer alarmRefsBad=create          

...

bool processModule(string moduleFullName,ModuleVersion modVer)
{
    ...
    int i,id,idAlarm,alarmRefCount,alarmRefCountTTL=0
    string alarmRefsArray[],alarmRefsArrayOrig[]
    string alarmText,alarmRefText,alarmRefTextOrig
    bool foundAlarm
    bool hasLink
    int alarmRefGoodCount=0,alarmRefMissingLinkCount=0,alarmRefBadCount=0
    Module mproc //module handle that will be used 
    Object o
    Object oAlarm

    ...

        //GET ALL REQUIREMENTS WITH ALARM REFERENCES:
        //-------------------------------------------
        if (!getAlarmReferences(mproc,alarmReferences)) 
        {
            resultMsg+="NO ALARM REFERENCES FOUND IN ANY MODULE REQUIREMENTS - SKIPPING MODULE\n"
            return(true) 
        }

        //VALIDATE EACH ALARM REFERENCE HAS LINK TO THAT ALARM:
        //-----------------------------------------------------
        alarmRefsGood=""
        alarmRefsMissingLink=""
        alarmRefsBad=""
        for alarmRefsArray in alarmReferences do
        {
            o=(Object key alarmReferences)
            if (null o) { errorBox "ERROR - couldn't retrieve object key for current module \"" moduleFullName "\". Aborting."; abortScript() }
            if (!find(alarmReferencesOrig,o,alarmRefsArrayOrig)) { errorBox "ERROR - couldn't retrieve original alarm reference text! Aborting."; abortScript() }
            id=o."Absolute Number"  //LINE 1435 - WHAT IS WRONG HERE?? LOOKS OK
            alarmRefCount=sizeof(alarmRefsArray)
            for (i=0; i<alarmRefCount; i++)
            {
                alarmRefCountTTL++
                alarmRefText=alarmRefsArray[i]
                alarmRefTextOrig=alarmRefsArrayOrig[i]
                foundAlarm=false //assume we won't find alarm from alarm module that matches the current alarm reference (alarmRefText) found in requirement object o
                for oAlarm in alarmObjects do
                {
                    alarmText=""
                    if (! null oAlarm) { alarmText=trimOuterWhitespace(oAlarm."Object Text""") }
                    if (alarmText==alarmRefText)
                    {
                        foundAlarm=true
                        hasLink=checkForLink(oAlarm,o)
                        idAlarm=oAlarm."Absolute Number"
                        break
                    }
                }
                //FOR CURRENT ALARM REFERENCE, UPDATE APPROPRIATE BUFFER WITH RESULTS INFO:
                //-------------------------------------------------------------------------
                if (foundAlarm && hasLink) { alarmRefsGood+=id "<-[Alarm " idAlarm "], "; alarmRefGoodCount++ }
                else if (foundAlarm && !hasLink) { alarmRefsMissingLink+=formatRTF__T(RTF_RED__T,"ID " id "<-[Alarm " idAlarm "]") ", "; alarmRefMissingLinkCount++ }
                else { alarmRefsBad+=formatRTF__T(RTF_RED__T|RTF_BOLD__T,"BAD ID " id ": No matching alarm found for alarm reference \"" alarmRefTextOrig "\".\n"); alarmRefBadCount++ }
            }
        }
        //FOR CURRENT ALARM REFERENCE, UPDATE APPROPRIATE BUFFER WITH RESULTS INFO:
        //-------------------------------------------------------------------------
        if (length(alarmRefsGood)>2) { length(alarmRefsGood,length(alarmRefsGood)-2) } //remove trailing ", " on last entry
        if (length(alarmRefsMissingLink)>2) { length(alarmRefsMissingLink,length(alarmRefsMissingLink)-2) } //remove trailing ", " on last entry
        resultMsg+="Processed " alarmRefCountTTL " alarm references found in the requirements for this module with these results:\n"
        if (length(alarmRefsGood)>0)        { resultMsg+=alarmRefGoodCount " GOOD ALARM REFERENCE(S) IN MODULE (linked alarm found): " alarmRefsGood "\n" }
        if (length(alarmRefsMissingLink)>0) { resultMsg+=alarmRefMissingLinkCount " BAD ALARM REFERENCE(S) IN MODULE - ALARM FOUND BUT NOT ACTUALLY LINKED: " alarmRefsMissingLink "\n" }
        if (length(alarmRefsBad)>0)         { resultMsg+=formatRTF__T(RTF_RED__T|RTF_BOLD__T,alarmRefBadCount " BAD ALARM REFERENCE(S) IN MODULE - NO MATCHING ALARM FOUND:\n"); resultMsg+=alarmRefsBad }
    }

    //CLOSE THE MODULE, IF IT WAS NOT PREVIOUSLY OPEN AND WE OPENED IT:
    //-----------------------------------------------------------------
    ...

    //RETURN PROCESSING STATUS:
    return(returnStatus)
}//end: bool processModule(string moduleFullName,ModuleVersion modVer

strathglass - Tue Apr 11 20:54:33 EDT 2017

Re: An unexpected error has occurred...
O.Wilkop - Wed Apr 12 04:16:17 EDT 2017

Are you sure the key is a object? Cause if you look at the following snippet you will get the same result:

 

Skip sl = create();
put(sl, 1, 1);

int i;
for i in sl do {
        Object o = (Object key sl);
        if(null o) print "null";
        int j = o."Absolute Number";
}

 

The null check doesn't catch the non-valid object, and once you try to do something with it the program crashes.

Re: An unexpected error has occurred...
Mike.Scharnow - Wed Apr 12 06:03:55 EDT 2017

Or the module that contains o might have been closed after alarmReferences was filled

Re: An unexpected error has occurred...
strathglass - Wed Apr 12 07:59:32 EDT 2017

Thanks guys, both good thoughts on what the issue could be.

 

Now as to Object key, I am definitely using an Object as the key in the function that gets populates the Skip list. So it is not that.

 

But I think Mike found the problem: its not that I didn't have the module open, it is that I didn't empty the skip lists before processing a new module.

So actually, no - I didn't have the module open because after doing one module, I close it, but for the next module, I add entries to the skip lists without deleting the old module's entries.

Hence when I loop through the skip list, I am getting not only objects for the current module, but also for the old module that WAS NOW CLOSED! Bingo - problem found.

I just added a call at the start of the processing for each module to a routine that empties the skip of all current contents.

That seems to have fixed it! :)

 

Thanks again.